package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GxInterface;
import com.ruoyi.system.service.IGxInterfaceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 接口Controller
 * 
 * @author ruoyi
 * @date 2023-07-11
 */
@RestController
@RequestMapping("/system/interface")
public class GxInterfaceController extends BaseController
{
    @Autowired
    private IGxInterfaceService gxInterfaceService;

    /**
     * 查询接口列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GxInterface gxInterface)
    {
        startPage();
        List<GxInterface> list = gxInterfaceService.selectGxInterfaceList(gxInterface);
        return getDataTable(list);
    }


    /**
     * 获取接口详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gxInterfaceService.selectGxInterfaceById(id));
    }

    /**
     * 新增接口
     */
    @Log(title = "接口", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GxInterface gxInterface)
    {
        return toAjax(gxInterfaceService.insertGxInterface(gxInterface));
    }

    /**
     * 修改接口
     */
    @Log(title = "接口", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GxInterface gxInterface)
    {
        return toAjax(gxInterfaceService.updateGxInterface(gxInterface));
    }

    /**
     * 删除接口
     */
    @Log(title = "接口", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gxInterfaceService.deleteGxInterfaceByIds(ids));
    }
}
